﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace final_darskade.Controllers
{
    public class PrivilegeController : Controller
    {
        //
        // GET: /Privilege/

        public ActionResult Index()
        {
            return Redirect("/");
        }

        [HttpGet]
        public ActionResult prof_privilegeList(int? klassid)
        {
            if (klassid == null) Redirect("/");
            string a = (string)Session["UserName"];

            var query = from user in Helper.database.users
                        where a == user.username
                        select user.user_id;
            if (query.Any() == false)
                return Redirect("/");
            int profid = query.First();
            if(false)
            //if (Helper.checkPrivilege(profid, "profgive_privilege", klassid.Value) == false)
            {
                return Redirect("/");
            }
            var query2 = from privilege in Helper.database.klass_members
                         where privilege.klass_id == klassid
                         select privilege;
            return View(query2.ToList());
        }
    }
}
